package com.yanmaohu.yulia.bean;

/**
 * @author Bright Lee
 */
public final class SortSpecification {

    private int beginIndex;
    private int endIndex;
    private ValueExpression sortKey;
    private OrderingSpecification orderingSpecification;
    private NullOrdering nullOrdering;

    public SortSpecification(ValueExpression sortKey,
                             OrderingSpecification orderingSpecification,
                             NullOrdering nullOrdering) {
        this.beginIndex = sortKey.getBeginIndex();
        this.endIndex = sortKey.getEndIndex();
        if (orderingSpecification != null) {
            this.endIndex = orderingSpecification.getEndIndex();
        }
        if (nullOrdering != null) {
            this.endIndex = nullOrdering.getEndIndex();
        }
        this.sortKey = sortKey;
        this.orderingSpecification = orderingSpecification;
        this.nullOrdering = nullOrdering;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public ValueExpression getSortKey() {
        return sortKey;
    }

    public OrderingSpecification getOrderingSpecification() {
        return orderingSpecification;
    }

    public NullOrdering getNullOrdering() {
        return nullOrdering;
    }

}
